<!DOCTYPE html>
<html>
	<!--
		作者：offline
		时间：2018-06-27
		描述：员工信息修改
	-->

	<head>
		<!-- 引入框架文件 -->
		<link rel="stylesheet" href="../../model/bootstrap-3.3.7-dist/css/bootstrap.min.css" />
		<script type="text/javascript" src="../../model/jquery-2.1.0.js"></script>
		<script type="text/javascript" src="../../model/bootstrap-3.3.7-dist/js/bootstrap.js"></script>
		<script type="text/javascript" src="../../model/models.js"></script>
		<script type="text/javascript" src="../../model/dispose.js"></script>
		<meta charset="UTF-8">
		<style type="text/css">
			.content input {
				width: 50%;
			}
			.content select {
				width: 50%;
			}
			.content span {
				margin: 5px 5px;
			}
		</style>
		<title></title>
	</head>

	<body>

		<div include="../../static/header.htm"></div>
		<div style="height: 100%;float: left;" include="../../static/aside.htm"></div>

		<div class="aside2">
			<div include="../../static/empManage.htm"></div>
		</div>

		<div class="section">
			<div style="color: white;font-size: 36px;text-align: center; width: 100%; height: 70px;" class="head"><b>信息修改</b></div>
			<div class="content">
				<!-- 查询框 -->
				<div style="margin-bottom: 5px;">
					<form id="queryEmpByCon">
						<input id="cont" placeholder="员工编号/姓名" class="form-control" style="width: 250px; float: left;margin-right: 10px;"/>
						<input style="margin: 2px 5px; width: 100px;" type="submit" value="查询" class="btn btn-danger" />

						<!--<span>员工编号：</span>
						<select class="select" style="width:80px; height:30px; color:#03F">
							<option value="saab">007</option>
						</select>-->
					</form>
				</div>
				<!-- 员工信息显示form -->
				<form id="updateEmp">
					<table class="table table-bordered">
						<tr>
							<td>
								<div class="left">
									<span>姓　　名：</span>
									<input id="empName" name="empName" type="text" class="form-control" readonly/>
									<input id="id" type="hidden" name="id" />
								</div>
							</td>
							<td>
								<div class="right">
									<span>入职日期：</span>
									<input id="empEntryDate" name="empEntryDate" value="2018-09-24" type="date" class="form-control"/>
								</div>
							</td>
						</tr>
						<tr>
							<td>
								<div class="left">
									<span>性　　别：</span>
									<input id="empSex" name="empSex" value="男" class="form-control"/>

								</div>
							</td>
							<td>
								<div class="right">
									<span>工作日期：</span>
									<input id="empJopDate" name="empJopDate" value="2018-09-24" type="date" class="form-control"/>
								</div>
							</td>
						</tr>
						<tr>
							<td>
								<div class="left">
									<span>出生日期：</span>
									<input id="gradDate" name="gradDate" value="2018-09-24" type="date" class="form-control"/>
								</div>
							</td>
							<td>
								<div class="right">
									<span>籍　　贯：</span>
									<input id="nativePlace" name="nativePlace" type="text" class="form-control"/>
								</div>
							</td>
						</tr>
						<tr>
							<td>
								<div class="left">
									<span>身份证号：</span>
									<input id="idNumber" name="idNumber" type="text" class="form-control"/>
								</div>
							</td>
							<td>
								<div class="right">
									<span>联系电话：</span>
									<input id="empPh" name="empPh" type="text" class="form-control"/>
								</div>
							</td>
						</tr>
						<tr>
							<td>
								<div class="left">
									<span>部　　门：</span>
									<select id="empDiv" name="empDiv.id" class="form-control">
										<option value="1">管理</option>
										<option value="2">后勤</option>
									</select>
								</div>
							</td>
							<td>
								<div class="right">
									<span>电子邮件：</span>
									<input id="empBox" name="empBox" type="text" class="form-control"/>
								</div>
							</td>
						</tr>
						<tr>
							<td>
								<div class="left">
									<span>岗　　位：</span>
									<select id="empPost" name="empPost.id" class="form-control">
										<option value="1">Java工程师</option>
										<option value="2">Java高级工程师</option>
									</select>
								</div>
							</td>
							<td>
								<div class="right">
									<span>身　　高：</span>
									<input id="stature" name="stature" type="text" class="form-control"/>
								</div>
							</td>
						</tr>
						<tr>
							<td>
								<div class="left">
									<span>户口地址：</span>
									<input id="empResidence" name="empResidence" type="text" class="form-control"/>
								</div>
							</td>
							<td>
								<div class="right">
									<span>所学专业：</span>
									<input id="specialty" name="specialty" type="text" class="form-control"/>
								</div>
							</td>
						</tr>
						<tr>
							<td>
								<div class="left">
									<span>毕业院校：</span>
									<input id="empSh" name="empSh" type="text" class="form-control"/>
								</div>
							</td>
							<td>
								<div class="right">
									<span>毕业日期：</span>
									<input id="gradDate" name="gradDate" value="2018-09-24" type="date" class="form-control" />
								</div>
							</td>
						</tr>

						<tr>
							<td>
								<div class="left-se">
									<span>政治面貌：</span>
									<select id="polStatus" name="polStatus" class="form-control" style="width: 130px;">
										<option value="预备党员">预备党员</option>
										<option value="团员">团员</option>
										<option value="其他">其他</option>
									</select>
								</div>

								<div class="right-se">
									<span>用工形式：</span>
									<select id="modality" name="modality" class="form-control" style="width: 130px;">
										<option value="正式员工">正式员工</option>
										<option value="临时员工">临时员工</option>
									</select>
								</div>
							</td>
							<td>
								<div class="left-se">
									<span>最高学位：</span>
									<select id="maxDegree" name="maxDegree" class="form-control" style="width: 130px;">
										<option value="无学位">无学位</option>
										<option value="学士">学士</option>
										<option value="双学士">双学士</option>
										<option value="硕士">硕士</option>
										<option value="博士">博士</option>
										<option value="博士后">博士后</option>
									</select>
								</div>

								<div class="right-se">
									<span>最高学历：</span>
									<select id="eduBack" name="eduBack" class="form-control" style="width: 130px;">
										<option value="高中及以下">高中及以下</option>
										<option value="大专">大专</option>
										<option value="本科">本科</option>
										<option value="研究生">研究生</option>
									</select>
								</div>
							</td>
						</tr>

						<tr>
							<td>
								<div class="left-se">
									<span>人员来源：</span>
									<select id="empSource" name="empSource" class="form-control" style="width: 130px;">
										<option value="校园招聘">校园招聘</option>
										<option value="社会招聘">社会招聘</option>
										<option value="其他">其他</option>
									</select>
								</div>

								<div class="right-se">
									<span>民　　族：</span>
									<select id="nationality" name="nationality" class="form-control" style="width: 130px;">
										<option value="汉族">汉族</option>
										<option value="回族">回族</option>
									</select>
								</div>
							</td>
							<td>
								<div class="left-se">
									<span>血　　型：</span>
									<select id="bloodType" name="bloodType" class="form-control" style="width: 130px;">
										<option value="A 型">A 型</option>
										<option value="B 型">B 型</option>
										<option value="AB型">AB型</option>
										<option value="0 型">0 型</option>
										<option value="其他血型">其他血型</option>
									</select>
								</div>

								<div class="right-se">
									<span>婚姻状况：</span>
									<select id="marriage" name="marriage" class="form-control" style="width: 130px;">
										<option value="未婚">未婚</option>
										<option value="已婚">已婚</option>
										<option value="丧偶">丧偶</option>
										<option value="离婚">离婚</option>
									</select>
								</div>
							</td>
						</tr>
					</table>
					<input type="hidden" id="available" name="available" />
					<!-- 提交按钮 -->
					<div style="margin: 0 auto; width: 200px; height: 50px; margin-top: 20px;">
						<input class="btn btn-danger" style="width: 200px;" type="submit" value="提交" />
					</div>
				</form>
			</div>
		</div>
	</body>
	<script type="text/javascript">
		// 查询所有的部门信息并进行下拉框更新 传入select的id名
		findPostAll("empPost");
		// 查询所有的岗位信息并进行下拉框更新 传入select的id名
		findDepaAll("empDiv");
		
		var id = getUrlParam("id");

		if(null != id) {
			$.ajax({
				type: "post",
				url: "http://localhost:9090/findEmpById?id=" + id,
				"success": function(obj) {
					if(obj.data != null) {
						var emp = obj.data;
						for(var index in emp) {
							if("empDiv" == index && emp[index] != null)
								$("#" + index).val(emp[index].id);
							else if("empPost" == index && emp[index] != null)
								$("#" + index).val(emp[index].id)
							else
								$("#" + index).val(emp[index]);
						}
					} else
						window.wxc.xcConfirm("无此用户！", window.wxc.xcConfirm.typeEnum.error);
				},
				"dataType": "json",
				async: true
			});
		}

		$("#queryEmpByCon").submit(function(e) {
			var cont = $("#cont").val();
			//阻止表单默认事件,不让表单跳转到其它页面
			e.preventDefault();

			//jq的回调函数中的this,一般表示该事件源,即触发事件的元素
			var $self = $(this);

			//$self.serialize(); 将表单中的数据进行序列化
			//async:true 采用异步操作
			$.ajax({
				type: "post",
				url: "http://localhost:9090/findEmpByKey?key=" + cont + "&page=1",
				"data": $self.serialize(),
				"success": function(obj) {
					if(obj.data != null) {
						var emp = obj.data;
						for(var index in emp) {
							if("empDiv" == index && emp[index] != null)
								$("#" + index).val(emp[index].id);
							else if("empPost" == index && emp[index] != null)
								$("#" + index).val(emp[index].id)
							else
								$("#" + index).val(emp[index]);
						}
					} else
						window.wxc.xcConfirm("无此用户！", window.wxc.xcConfirm.typeEnum.error);
				},
				"dataType": "json",
				async: true
			});

		});

		$("#updateEmp").submit(function(e) {

			//阻止表单默认事件,不让表单跳转到其它页面
			e.preventDefault();
			//jq的回调函数中的this,一般表示该事件源,即触发事件的元素
			var $self = $(this);
			//$self.serialize(); 将表单中的数据进行序列化
			//async:true 采用异步操作
			$.ajax({
				type: "post",
				"url": "http://localhost:9090/updateEmp",
				"data": $self.serialize(),
				"success": function(obj) {
					if(obj.data) {
						window.wxc.xcConfirm("更新成功！", "success");
					} else
						window.wxc.xcConfirm("更新失败！", window.wxc.xcConfirm.typeEnum.error);
				},
				"dataType": "json",
				async: true
			});
		});
	</script>

</html>